/**
 * Created by jerome.arnoult on 15/05/14.
 */
var domainOriginGame = "http://warnoid.com/client/";


var game;
$('document').ready(function(){
    game = new main("canvasGame");
    game.loadMods();
})

function main(idCanvas){
    this.canvasBox = idCanvas;
    this.stage = new createjs.Stage(idCanvas);
    this.stage.autoClear = true;
    this.context = document.getElementById(idCanvas).getContext("2d");
    this.mainContainer;
}

main.prototype.loadMods = function(){
    if(debugGame === true)
        this.gameDebug = new gamedebug();
    this.gameRenderer = new gamerenderer(this.canvasBox, this.stage);
    this.gameRoom = new gameroom("readyroom");
    this.gameRoom.load();
    this.gameGui = new gamegui();
    this.gameRenderer.renderingLoop();

    var WebSocket = window.WebSocket || window.MozWebSocket;

    var client = new WebSocket("ws://127.0.0.1");
    $client = $(client);

    $client.bind("message", function(evt) {
        console.log(evt.originalEvent);
        client.close();
    });
    $client.bind('close', function(evt) {
        console.log(evt.originalEvent);
    });
    $client.bind('error', function(evt) {
        console.log(evt.originalEvent);
    });
    $client.bind('open', function(evt) {
        console.log(evt.originalEvent);
        client.send("message from client");
    });
}